/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved. 
 */
package com.icinfo.cloud.provider.punish.ucase.casemain.controller;

import com.icinfo.cloud.common.core.page.PageResponse;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CaseAppendEvidenceDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CaseEvidenceShareQueryDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.service.ICaseMainEvidenceService;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseMainEvidenceVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;

/**
 * 描述: 案件证据表-trj case_main_evidence 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年02月15日
 */
@RestController
@RequestMapping("/evidence")
public class CaseMainEvidenceController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(CaseMainEvidenceController.class);

    @Autowired
    private ICaseMainEvidenceService caseMainEvidenceService;

    /**
     * 查询证照库案件证据列表
     */
    @PostMapping("/getList")
    public Result<PageResponse<CaseMainEvidenceVo>> getList(@Validated @RequestBody CaseEvidenceShareQueryDto caseEvidenceShareQueryDto){
        return Result.success(caseMainEvidenceService.getEvidenceList(caseEvidenceShareQueryDto));
    }

    /**
     * 删除草稿
     */
    @PostMapping("/removeShareEvidence/{uid}")
    public Result removeShareEvidence(@NotBlank(message = "uid不能为空") @PathVariable("uid") String uid){
        if (caseMainEvidenceService.removeShareEvidence(uid)){
            return Result.success("删除成功");
        }
        return Result.error("删除失败");
    }

    /**
     * 证据材料补充
     * @param caseAppendEvidenceDto
     * @return: com.icinfo.framework.common.web.Result
     * @author sunjiefei
     * @date 2023-04-19
     */
    @PostMapping("/appendEvidence")
    public Result appendEvidence(@Validated @RequestBody CaseAppendEvidenceDto caseAppendEvidenceDto){
        caseMainEvidenceService.appendEvidence(caseAppendEvidenceDto);
        return Result.success("证据材料补充成功");
    }

    /**
     * 获取证据材料补充
     * @param caseId
     * @return: com.icinfo.framework.common.web.Result
     * @author sunjiefei
     * @date 2023-04-19
     */
    @GetMapping("/getAppendEvidence")
    public Result getAppendEvidence(String caseId){
        CaseAppendEvidenceDto caseAppendEvidenceDto = caseMainEvidenceService.getAppendEvidence(caseId);
        return Result.success(caseAppendEvidenceDto);
    }

}